<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page import="static com.gmail.avereshchaga.tools.UrlList.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Employees List</title>
    </head>

    <body>
        <table class="loctable">
            <tr><td valign="top">
        
		<%@ include file="login.jsp" %> 
		
		<b><spring:message code="label.employees.list"/>:</b>
		
		<table cellspacing="10">
            <tr>
                <td>
                    <form:form style = "display:inline !important;" commandName="Search" method="post"> 
                    <input type="text" name="searchQuery" value="${searchQuery}">
                    <input type="submit" value="<spring:message code="label.search"/>" />
                    </form:form>
                </td>
                <td>
                    <form:form style = "display:inline !important;" commandName="Cleaning" method="post" >
                    <input type="hidden" name="cleaning" value="true">
                    <input type="submit" value="<spring:message code="label.cleaning"/>" />
                    </form:form>
                </td>
            </tr> 
        </table>
        
        <c:choose>
            <c:when test = "${msg}">
                <b style="color:red;"><spring:message code="label.search.msg"/></b>
            </c:when>
        </c:choose> 
 
        <table cellspacing="10" cellpadding=0>
            <c:forEach items="${employees}" var="employee">
            <tr style="line-height: 5px;">
                <td><a href="<%=EMPLOYEE_READ_URL%>/${employee.id}"><c:out value="${employee.firstName}" /></a></td>
                <td><a href="<%=EMPLOYEE_READ_URL%>/${employee.id}"><c:out value="${employee.lastName}" /></a></td>
                    <sec:authorize access="isAuthenticated()">
                        <c:choose>
                          <c:when test="${employee.active=='true'}">
                            <td><a href="<%=EMPLOYEE_UPDATE_URL%>/${employee.id}" class="cref"><spring:message code="label.edit"/></a></td>
                          </c:when>
                          <c:when test="${employee.active=='false'}">
                            <td><spring:message code="label.edit"/></td>
                          </c:when>
                        </c:choose>
                    </sec:authorize>
            </tr>
            </c:forEach> 
		</table> 

		</td>
		</tr>

        <tr valign="bottom">
            <td> 
            <c:forEach items="${pages}" var="page">
            <form:form class="xform" style = "display:inline !important;" commandName="Switching" method="post">
                <input type="hidden" name="page" value="${page}">
                <input type="submit" value="${page+1}" /> 
            </form:form>
            </c:forEach>
            </td> 
        </tr>  
         
        </table>
    </body>
</html>
